/*     */ package com.qmsk.business.member.bank.controller;
/*     */ 
/*     */ import com.qmsk.business.member.bank.dao.BankDAO;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/bank"})
/*     */ public class BankController
/*     */ {
/*  32 */   private static final Logger logger = Logger.getLogger(BankController.class);
/*     */ 
/*     */   @Autowired
/*     */   private BankDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  51 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  53 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  54 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  56 */       logger.error(e);
/*  57 */       ResponseUtils.setErrorMsgResponse(
/*  58 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  76 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  78 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  79 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  81 */       logger.error(e);
/*  82 */       ResponseUtils.setErrorMsgResponse(
/*  83 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/{id}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 102 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 104 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(id, nPageIdx, 
/* 105 */         nPageSize);
/* 106 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 108 */       logger.error(e);
/* 109 */       ResponseUtils.setErrorMsgResponse(
/* 110 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 127 */       int nResult = 0;
/* 128 */       Long id = null;
/* 129 */       String sData = RequestUtils.getStringOfData(request);
/* 130 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 131 */       if (p != null) {
/* 132 */         nResult = this.dao.applyUpdates(p);
/* 133 */         if (nResult > 0) {
/* 134 */           id = this.dao.getLastId();
/* 135 */           DbConnection.commit();
/*     */         } else {
/* 137 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 140 */       if (id != null) {
/* 141 */         String[] heads = { "id" };
/* 142 */         Object[] datas = { id };
/* 143 */         ResponseUtils.toGsonEbRst(heads, datas, response);
/* 144 */         return; }
/* 145 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 146 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 147 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 150 */       logger.error(e);
/* 151 */       DbConnection.rollback();
/* 152 */       ResponseUtils.setErrorMsgResponse(
/* 153 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 154 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 170 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 172 */       String[] strParams = id.split(",");
/* 173 */       int nResult = this.dao.deleteParams(strParams);
/* 174 */       DbConnection.commit();
/* 175 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 176 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 177 */         response);
/*     */     } catch (Exception e) {
/* 179 */       DbConnection.rollback();
/* 180 */       logger.error(e);
/* 181 */       ResponseUtils.setErrorMsgResponse(
/* 182 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 183 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 199 */     String sData = RequestUtils.getStringOfData(request);
/*     */     try {
/* 201 */       int nResult = 0;
/* 202 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 203 */       if (p != null) {
/* 204 */         nResult = this.dao.applyUpdates(p);
/* 205 */         if (nResult > 0)
/* 206 */           DbConnection.commit();
/*     */         else {
/* 208 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 212 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 213 */         RequestUtils.getSqlUpdateErrorMessage(sData, request), 
/* 214 */         response);
/*     */     } catch (Exception e) {
/* 216 */       DbConnection.rollback();
/* 217 */       logger.error(e);
/* 218 */       ResponseUtils.setErrorMsgResponse(
/* 219 */         RequestUtils.getSqlUpdateErrorMessage(sData, request) + 
/* 220 */         ":" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.bank.controller.BankController
 * JD-Core Version:    0.5.3
 */